package com.lagou.controller;

import com.alibaba.druid.pool.DruidDataSource;

public class DBUtil {

    private static DruidDataSource druidDataSource = null;

    private DBUtil() {
    }

    public static synchronized void setDruidDataSource(String driverName, String Url, String Username, String password) {
        if (druidDataSource != null) {
            druidDataSource.close();
        }
        druidDataSource = new DruidDataSource();
        druidDataSource.setDriverClassName(driverName);
        druidDataSource.setUrl(Url);
        druidDataSource.setUsername(Username);
        druidDataSource.setPassword(password);
    }

    public static DruidDataSource getInstance() {
        return druidDataSource;
    }

}
